package com.utils;

import com.mchange.v2.c3p0.ComboPooledDataSource;
import org.apache.commons.dbutils.QueryRunner;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Myutils {

    public static final QueryRunner qr=new QueryRunner(new ComboPooledDataSource());

    /**
     * 把复选框字符串数组--->字符串
     * @param arr
     * @return
     */
    public static String arrayToString(String[] arr){
        String str="";
        for (String s : arr) {
            str+=","+s;
        }
        return str.substring(1,str.length());
    }

    /**
     * 把字符串转成Date
     * @param str
     * @return
     */
    public static Date stringToDate(String str){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try {
            Date date = sdf.parse(str);
            return date;
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return null;
    }
}
